package com.miyake.client.tools;

import com.google.gwt.event.logical.shared.CloseEvent;
import com.google.gwt.event.logical.shared.CloseHandler;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.PopupPanel;

public abstract class ShowDialog {
	protected abstract void onOK(String text);
	protected abstract DialogBox getDialogBox();
	
	protected  ShowDialog() {
		final DialogBox dlg = getDialogBox();
		dlg.center();
		dlg.addCloseHandler(new CloseHandler<PopupPanel>() {
			@Override
			public void onClose(CloseEvent<PopupPanel> event) {
				if (!event.isAutoClosed()) {
					onOK(dlg.getText());
				}
			}
		});
	}
}
